<div style="height:20px"></div>

<% session[:schedule] ||= {} %>
<% session[:schedule][:showing_instructor_block_page] = true %>

<script type="text/javascript">
displaying_new_reservation_form = false
</script>
<%= render_partial 'reservation/schedule_browser'%>
<% reservation = @reservation%>
<h3>Create a One-Time Block</h3>
 <i> I am unavailable: </i>
  <%=  start_form_tag :controller => 'schedule',:action => 'new_instructor_block' %>
              <table>
				<tr>
			    <td style="text-align:left;"><label>From: </label></td><td>
				    <select id='s_year' name="s_year">
				    <%= options_for_select [Time.new.year,Time.new.year+1],reservation.time_start.year%>
				    </select>
				    <select id='s_month' name="s_month">
				    <%= options_for_select (1..12).map{|x| x},reservation.time_start.month%>
				    </select>
				    <select id='s_day' name="s_day">
				    <%= options_for_select (1..31).map{|x| x},reservation.time_start.day%>
				    </select>
				    <select name="s_hour">
				    <%= options_for_select [['12 am',0]]+(1..11).map{|x| [x.to_s+' am',x]}+[['12 pm',12]]+(1..11).map{|x| [x.to_s+' pm',x+12]},
				            reservation.time_start.hour%>
				    </select>
			    </td>
			    </tr><tr>
			    <td style="text-align:left;"><label>To: </label> </td><td>
				    <select id="e_year" name="e_year">
				    <%= options_for_select [Time.new.year,Time.new.year+1],reservation.time_end.year%>
				    </select>
				    <select id="e_month" name="e_month">
				    <%= options_for_select (1..12).map{|x| x},reservation.time_end.month%>
				    </select>
				    <select id='e_day' name="e_day">
				    <%= options_for_select (1..31).map{|x| x},reservation.time_end.day%>
				    </select>
				    <select name="e_hour">
				    <%= options_for_select [['12 am',0]]+(1..11).map{|x| [x.to_s+' am',x]}+[['12 pm',12]]+(1..11).map{|x| [x.to_s+' pm',x+12]},
				            reservation.time_end.hour%>
				    </select>
			    </td></tr>
			    </table>
       
        <%= submit_tag 'Create Block'%>
          <%= end_form_tag %>


<h3>Create a Pattern of Blocks</h3>
 <i> I am unavailable on: </i>
<%=  start_form_tag :controller => 'schedule',:action => 'new_instructor_block_pattern' %>
		 		 <%=check_box_tag "days[1]",'true', false %> Mon
				 <%=check_box_tag "days[2]",'true', false %> Tue
				 <%=check_box_tag "days[3]",'true', false %> Wed
				 <%=check_box_tag "days[4]",'true', false %> Thu
				 <%=check_box_tag "days[5]",'true', false %> Fri
				 <%=check_box_tag "days[6]",'true', false %> Sat 
				 <%=check_box_tag "days[7]",'true', false %> Sun    
        <table>
	
				<tr>
			    <td style="text-align:left;"><label>From: </label></td><td>
			    <select name="from">
			    <%= options_for_select [['12 am',0]]+(1..11).map{|x| [x.to_s+' am',x]}+[['12 pm',12]]+(1..11).map{|x| [x.to_s+' pm',x+12]},
			            reservation.time_start.hour%>
			    </select>
			    </td>
			    </tr><tr>
			    <td style="text-align:left;"><label>To: </label> </td><td>
			    <select name="to">
			    <%= options_for_select [['12 am',0]]+(1..11).map{|x| [x.to_s+' am',x]}+[['12 pm',12]]+(1..11).map{|x| [x.to_s+' pm',x+12]},
			            reservation.time_end.hour%>
			    </select>
			    </td></tr>
			
					<tr>
				    <td style="text-align:left;"><label>Starting: </label></td><td>
				   		    <select id="s_year2" name="s_year">
						    <%= options_for_select [Time.new.year,Time.new.year+1],reservation.time_start.year%>
						    </select>
						    <select id="s_month2" name="s_month">
						    <%= options_for_select (1..12).map{|x| x},reservation.time_start.month%>
						    </select>
						    <select id="s_day2" name="s_day">
						    <%= options_for_select (1..31).map{|x| x},reservation.time_start.day%>
						    </select>
				    </td>
				    </tr><tr>
				    <td style="text-align:left;"><label>Ending: </label> </td><td>
						    <select id="e_year2" name="e_year">
						    <%= options_for_select [Time.new.year,Time.new.year+1],reservation.time_start.year%>
						    </select>
						    <select id="e_month2" name="e_month">
						    <%= options_for_select (1..12).map{|x| x},reservation.time_start.month%>
						    </select>
						    <select id="e_day2" name="e_day">
						    <%= options_for_select (1..31).map{|x| x},reservation.time_start.day%>
						    </select>
				    </td></tr>
			
			
			    </table>
     
      <%= submit_tag 'Create Block Pattern'%>
        <%= end_form_tag %>


		<h3>Clear Existing Blocks</h3>
		 <i> Clear blocks: </i>
		  <%=  start_form_tag :controller => 'schedule',:action => 'clear_instructor_blocks' %>
		              <table>
						<tr>
					    <td style="text-align:left;"><label>From: </label></td><td>
						    <select id="s_year3" name="s_year">
						    <%= options_for_select [Time.new.year,Time.new.year+1],reservation.time_start.year%>
						    </select>
						    <select id="s_month3" name="s_month">
						    <%= options_for_select (1..12).map{|x| x},reservation.time_start.month%>
						    </select>
						    <select id="s_day3" name="s_day">
						    <%= options_for_select (1..31).map{|x| x},reservation.time_start.day%>
						    </select>
			  			    <select name="s_hour">
            			    <%= options_for_select [['12 am',0]]+(1..11).map{|x| [x.to_s+' am',x]}+[['12 pm',12]]+(1..11).map{|x| [x.to_s+' pm',x+12]},
            			            0%>
            			    </select>
					    </td>
					    </tr><tr>
					    <td style="text-align:left;"><label>To: </label> </td><td>
						    <select id="e_year3" name="e_year">
						    <%= options_for_select [Time.new.year,Time.new.year+1],reservation.time_end.year%>
						    </select>
						    <select id="e_month3" name="e_month">
						    <%= options_for_select (1..12).map{|x| x},reservation.time_end.month%>
						    </select>
						    <select id="e_day3" name="e_day">
						    <%= options_for_select (1..31).map{|x| x},reservation.time_end.day%>
						    </select>
			  			    <select name="e_hour">
            			    <%= options_for_select [['12 am',0]]+(1..11).map{|x| [x.to_s+' am',x]}+[['12 pm',12]]+(1..11).map{|x| [x.to_s+' pm',x+12]},
            			            0%>
            			    </select>
					    </td></tr>
					    </table>

		        <%= submit_tag 'Clear Blocks'%>
		          <%= end_form_tag %>
		
<script type="text/javascript">
   new Form.Element.Observer('s_year',0,function(element,value){$('e_year').value=value})
   new Form.Element.Observer('s_month',0,function(element,value){$('e_month').value=value})
   new Form.Element.Observer('s_day',0,function(element,value){$('e_day').value=value})

   new Form.Element.Observer('s_year2',0,function(element,value){$('e_year2').value=value})
   new Form.Element.Observer('s_month2',0,function(element,value){$('e_month2').value=value})
   new Form.Element.Observer('s_day2',0,function(element,value){$('e_day2').value=value})

   new Form.Element.Observer('s_year3',0,function(element,value){$('e_year3').value=value})
   new Form.Element.Observer('s_month3',0,function(element,value){$('e_month3').value=value})
   new Form.Element.Observer('s_day3',0,function(element,value){$('e_day3').value=value})

</script>